<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<%@page import="com.tcs.model.User"%>
<%@ page session="true"%>
<%
	User usuario = null;
	HttpSession sesionOk = request.getSession();
	if (sesionOk.getAttribute("usuario") == null) {
%>
<jsp:forward page="index.jsp">
	<jsp:param name="error" value="Es obligatorio identificarse" />
</jsp:forward>
<%
	} else {
		usuario = (User) sesionOk.getAttribute("usuario");
	}
%>
<%
	//String stateNu = request.getParameter("state");
	String name = usuario.getFirstName();
%>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<%@ include file="include-head.html"%>



<script type="text/javascript">
function generaURL(from, to) {

  if (document.getElementById(from).value =="" || document.getElementById(to).value =="" ){
	 window.open('./listOfRequisitionByDate.html',_self);
	 
 } else {
	 var sDateFrom = new Date(document.getElementById(from).value).getTime()/1000;  
	  var sDateTo=new Date( document.getElementById(to).value).getTime()/1000;
	 window.open('./listOfRequisitionByDate.html?sinceDate='+sDateFrom+'&toDate='+sDateTo,'_self');
 };
  
 
 
	
}
</script>


</head>

<body>
	<!-- loading animation -->
	<div id="qLoverlay"></div>
	<div id="qLbar"></div>

	<jsp:include page="include-header.jsp" />

	<div id="wrapper">
		<!--Sidebar background-->
		<div id="sidebarbg"></div>


		<jsp:include page="include-sidebar.jsp" />

		<!--Body content-->
		<div id="content" class="clearfix">
			<div class="contentwrapper">
				<!--Content wrapper-->

				<div class="heading">
					<h3>Pedidos Abiertos</h3>
				</div>
				<!-- End .heading-->

				<!-- Build page from here: -->
				
				
				<div class="row-fluid">
					<div class="span12">


<div class="box">

                                <div class="title">

                                    <h4>
                                        <span>Filtrar Pedidos por Fecha:</span>
                                    </h4>
                                    
                                </div>


 <div class="form-row row-fluid" id="datePickform">
                                               
                                                   
                                                    <div class="span2">
                                                     <label class="form-label left" for="checkboxes">Desde:</label>                                                                                                   
                                                         <input type="text" id="datepickerfrom" />
                                                    </div>
                                                   
                                                    <div class="span2">
                                                      <label class="form-label left" for="checkboxes">Hasta:</label>                                                   
                                                       <input type="text" id="datepickerto" />
                                                     
                                                    </div>
                                                     <div class="span2">
                                                          <button class="btn"  onclick="generaURL('datepickerfrom', 'datepickerto')"><span class="icon16 brocco-icon-filter"></span> Filtrar</button>
                                                        
                                                      </div>
                                                </div>
                                          
                                         </div>
  
	                                       
						<!-- COMIENZO LISTADO TABLA DE PEDIDOS -->

						<div class="box chart gradient">
				<div class="title">
<h4>
									<a href="#" title="Descargar Reporte"
										onclick="generateexcel('Listado de Pedidos Inactivos', 'toXLS')"
										class="tip"><span class="icon16 icomoon-icon-download red"></span></a><span>Listado
										de Pedidos Abiertos Inactivos</span>

								</h4>
						


							</div>
							<div class="content noPad clearfix">

								<c:if test="${!empty requisitions}">
									<table id="toXLS" cellpadding="0" cellspacing="0" border="0"
										class="responsive dynamicTable display table table-bordered"
										width="100%">
										<thead>
											<tr>
												<th>Nro Pedido</th>
												<th>Nro Cliente</th>
												<th>Nombre</th>
												
												<th>Fecha</th>
												<th>Modificar Pedido</th>
												
											</tr>
										</thead>
										<c:forEach items="${requisitions}" var="requisition">
											<tr class="odd gradeX">
												<td><c:out value="${requisition.requisitionId}"/> </td>
												<td><c:out value="${requisition.user.userId}"/> </td>
												<td><c:out value="${requisition.user.firstName}"/> <c:out value="${requisition.user.lastName}"/>  </td>							
												
												<td><c:out value="${requisition.requisitionDate}" /></td>
											<td>	<a
															href="annulRequisition.html?id=<c:out value="${requisition.requisitionId}"/>"
															onclick="genera_ruta('http://localhost:8000/')"
															title="Anular" class="tip"><span
															class="icon12 icomoon-icon-remove"></span></a>
															</td>
												
											</tr>
										</c:forEach>
									</table>
								</c:if>



							</div>

						</div>
						<!-- End .box -->

					</div>

				

					<div class="marginB10"></div>

					<!-- End Span12 (ancho) -->
				</div>
				<!-- End .row-fluid -->
			</div>
			<!-- End contentwrapper -->
		</div>
		<!-- End #content -->
	</div>
	<!-- End #wrapper -->

<script type="text/javascript">
        // document ready function
        $(document).ready(function() {
            $("input, textarea, select").not('.nostyle').uniform();
            $("#datePickform").validate({
                rules: {
                	datepickerfrom: {
                        required: true
                      
                    },
                    datepickerto: {
                        required: true
                        
                 
                    }  
                },
                messages: {
                    username: {
                        required: "Campo requerido"
						
                    },
                    password: {
                        required: "Campo requerido"
                        
                    }
                }   
            });
        });
    </script>


	<%@ include file="include-javascript.html"%>
</body>



</html>




